package com.wman.sheeplib.api;

import android.content.Context;

import com.wman.sheep.okhttputils.OkHttpUtils;
import com.wman.sheep.okhttputils.cache.CacheMode;
import com.wman.sheep.okhttputils.callback.JsonCallback;
import com.wman.sheeplib.AppConfig;

import java.util.HashMap;

/**
 * 网络请求接口的实现
 */

public class ApiImpl implements Api {
    private Context context;

    public HashMap<String, String> mParams;

    public ApiImpl(Context context) {
        this.context = context;
    }

    @Override
    public void getTopList(String city, JsonCallback callback) {
        OkHttpUtils.get(AppConfig.BETA_SERVER_HEADER + GET_TOP_DATA)
                .tag(context)
                .params("city", city)
                .cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)
                .cacheKey("getTopList")
                .execute(callback);
    }

    @Override
    public void getThemeList(String city, int page, JsonCallback callback) {
        OkHttpUtils.get(AppConfig.BETA_SERVER_HEADER + GET_THEME_LIST)
                .tag(context)
                .params("city", city)
                .params("pageindex", page)
                .params("limit", AppConfig.LIMIT)
                .cacheMode(CacheMode.REQUEST_FAILED_READ_CACHE)
                .cacheKey("getThemeList")
                .execute(callback);
    }
}

